<?php

require "./includes/class.template.php";

$template = new verySimpleTemplate;

$coreHtmlOut = '';

$checkArray = array( 'pagerank' => array( 'TITLE'	 => '·Google Rank查询',
										  'DOACTION' => 'dopagerank',
										  'ACTION'	 => 'pagerank'
										),

					 'google'	=> array( 'TITLE'	 => '·Google收录查询',
										  'DOACTION' => 'dogoogle',
										  'ACTION'	 => 'google'
										),

					 'baidu'	=> array( 'TITLE'	 => '·Baidu收录查询',
										  'DOACTION' => 'dobaidu',
										  'ACTION'	 => 'baidu'
		 								),

					 'msn'		=> array( 'TITLE'	 => '·MSN收录查询',
										  'DOACTION' => 'domsn',
										  'ACTION'	 => 'msn'
										),

					 'yahoo'	=> array( 'TITLE'	 => '·Yahoo收录查询',
										  'DOACTION' => 'doyahoo',
										  'ACTION'	 => 'yahoo'
										),

					 'yisou'	=> array( 'TITLE'	 => '·Yisou收录查询',
										  'DOACTION' => 'doyisou',
										  'ACTION'	 => 'yisou'
										),

					 'sina'		=> array( 'TITLE'	 => '·Sina收录查询',
										  'DOACTION' => 'dosina',
										  'ACTION'	 => 'sina'
										),

					 'so163'	=> array( 'TITLE'	 => '·163收录查询',
										  'DOACTION' => 'doso163',
										  'ACTION'	 => 'so163'
										),

					 'qq'		=> array( 'TITLE'	 => '·QQ收录查询',
										  'DOACTION' => 'doqq',
										  'ACTION'	 => 'qq'
										),

					 'sohu'		=> array( 'TITLE'	 => '·Sohu收录查询',
										  'DOACTION' => 'dosohu',
										  'ACTION'	 => 'sohu'
										)
					);

if( @$_POST['site'] != 'show' )
{
	$template->deal( 'template/header.tpl' );
	$h = $template->template;

	$template->deal( 'template/site_free.tpl' );
	$b = $template->template;
	
	$template->deal( 'template/footer.tpl' );
	$f = $template->template;
	echo $h . $b . $f;
}
else
{

	$template->deal( 'template/header.tpl' );
	$h = $template->template;

	$domain   = $_POST['domain'];

	foreach( $checkArray as $checkKey => $checkVal )
	{
		if( @$_POST[$checkKey] )
		{
			$coreHtmlOut .= doTemplate( $checkVal );
		}
	}
	
	if( @$_POST['alexa'] )
	{
		$coreHtmlOut .= doAlexa();
	}

	if( @$_POST['whois'] )
	{
		$coreHtmlOut .= doWhois();
	}

	$arrayVar = array ( 'DETAIL_INFO'  => $coreHtmlOut, 'DOMAIN' => $domain );
	$template->deal( 'template/site_show.tpl', $arrayVar );
	$r = $template->template;
	
	$template->deal( 'template/footer.tpl' );
	$f = $template->template;
	echo $h . $r . $f;
}



function doTemplate( $arrayVar = array() )
{
	global $domain, $template;

	$domainArray = array( 'DOMAIN' => $domain );
	$arrayVar += $domainArray;
	$template->deal( 'template/site_render.tpl', $arrayVar );

	return $template->template;
}

function doAlexa()
{
	global $domain, $template;

	$arrayVar = array( 'DOMAIN' => $domain );
	$template->deal( 'template/site_alexaRender.tpl', $arrayVar );

	return $template->template;
}

function doWhois()
{
	global $domain, $template;

	$arrayVar = array( 'DOMAIN' => $domain );
	$template->deal( 'template/site_whoisRender.tpl', $arrayVar );

	return $template->template;
}
?>